package com.mms.imagegenius;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import java.util.ArrayList;

public class MainActivity extends Activity implements OnItemClickListener{

	private ArrayList<MenuListItem> menuList = new ArrayList<MenuListItem>();
	private ListView listView;
	Context context;

	/** Called when the activity is first created. */
	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		context = this;

		// initialize the menu items
		menuList.add(new MainMenuItem(R.drawable.ic_launcher, "Open Gallery", new Intent(this, GalleryActivity.class)));
		menuList.add(new MainMenuItem(R.drawable.ic_launcher, "Select Foreground", new Intent(this, SelectForegroundActivity.class)));
		
		setContentView(R.layout.activity_main);
		listView = (ListView) findViewById(R.id.lvMainMenu);
		// instead of setContentView
		listView.setAdapter(new ListViewImageTextAdapter(this, menuList, R.layout.main_menu_item));
		listView.setOnItemClickListener(this);
	}

	public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
		startActivity(menuList.get(position).getIntentToLaunch(this));
	}
	
	/*
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}
	*/
}
